<template>
	<pro-table
		ref="protable"
		rowKey="orgId"
		:loadDataUrl="api.getList"
		:columns="columns"
		:isAdd="$_has('sys:org:insert')"
		:isDelete="$_has('sys:org:delete')"
		:isHideOrgName="false"
		@selectedRowChange="onSelectChange"
		@addRecord="addRecord"
		@showDeleteConfirm="showDeleteConfirm"
	>
		<span class="tag" :class="{ active: text == 1 }"  slot="status" slot-scope="{ text, record }">{{ text == 0 ? '启用' : '停用' }}</span>
		<span slot="operation" slot-scope="{ text, record }" class="operation">
			<a href="javascript:;" v-has="'sys:org:update'" title="编辑" class="edit" @click="editRecord(record)">编辑</a>
			<a href="javascript:;" v-has="'sys:org:delete'" title="删除" class="del" @click="showDeleteConfirm(1, record.orgId, record.orgName)">删除</a>
		</span>
		<!-- 权限 -->
		<!-- 添加，编辑 -->
		<add-or-edit-org-modal :api="api" editKey="orgId" modalTitle="机构" ref="addOrEditModal" @ok="handlerRefresh"></add-or-edit-org-modal>
	</pro-table>
</template>

<script>
import proTable from '@/components/pro-table';
import { rowSelection, recordOperation } from '@/mixins';
import { sysManageapi } from '@/api/index.js';
import addOrEditOrgModal from './module/addOrEditOrgModal';
const columns = [
	{
		title: '机构名称',
		dataIndex: 'orgName', // data数据源中对应的字段
		key: 'orgName', // 列的关键字 如果有 dataIndex 则不需要key
		searchInfo: {
			type: 'string',
			defaultValue: ''
		},
		ellipsis: true
	},
	{
		title: '状态',
		dataIndex: 'status',
		key: 'status',
		scopedSlots: { customRender: 'status' },
		searchInfo: {
			type: 'select',
			defaultValue: undefined,
			optionlist: [
				{
					value: 0,
					text: '启用'
				},
				{
					value: 1,
					text: '停用'
				}
			]
		}
	},
	{
		title: '联系人',
		dataIndex: 'contacts',
		key: 'contacts',
		searchInfo: {
			type: 'string'
		},
		ellipsis: true
	},
	{
		title: '联系方式',
		dataIndex: 'phone',
		key: 'phone',
		ellipsis: true
	},
	{
		title: '添加时间',
		dataIndex: 'createTime',
		key: 'createTime',
		ellipsis: true,
		customRender: function(t, r, index) {
			return r.createTime?r.createTime.slice(0,10):'';
		},
	},

	{
		title: '备注',
		key: 'remark',
		dataIndex: 'remark',
		width: 300,
		ellipsis: true
	},
	{
		title: '操作',
		key: 'operation',
		scopedSlots: { customRender: 'operation' },
		align: 'center',
		width: 160,
		fixed: 'right'
	}
];
export default {
	name: 'orglist',
	mixins: [rowSelection, recordOperation],
	components: {
		proTable,
		addOrEditOrgModal
	},
	data() {
		return {
			columns: columns,
			api: sysManageapi.orgUrl
		};
	},
	created() {},
	methods: {}
};
</script>

<style scoped="scoped" lang="less"></style>
